<template>
	<view class="u-p-28 bg-white">

		<u-form :border-bottom="false" label-position="top" ref="uForm">
			<u-form-item :border-bottom="false">
				<u-input height="400" :clearable="false" :custom-style="textareaStyle" type="textarea" v-model="content"
					placeholder="请输入内容" />
			</u-form-item>


			<view class="submit">
				<view class="btn" @click="submit">发布</view>
			</view>
		</u-form>
	</view>
</template>

<script>
	import {
		publishComment
	} from '@/api/index';
	export default {
		data() {
			return {
				oid: '',
				type: '',
				textareaStyle: {
					background: '#F6F7FB',
					borderRadius: '4px',
					padding: '10px',
				},
			};
		},
		onLoad(options) {

			this.oid = options.oid;
			this.type = options.type;
			this.parent_id = options.parent_id;
		},
		methods: {

			async submit() {
				if (!this.content) {
					return uni.showToast({
						title: '请输入内容',
						icon: "none",
						mask: true,
					});
				}
				await publishComment({
					oid: this.oid,
					type: this.type,
					content: this.content,
					parent_id: this.parent_id, // 0表示一级评论，>0表示被回复的评论id
				});

				uni.showModal({
					showCancel: false,
					content: '您的留言信息已发布成功',
					confirmColor: '#333',
					success: (res) => {
						if (res.confirm) {
							uni.navigateBack();
						}
					}
				});
			},
		}
	}
</script>

<style lang="scss" scoped>
	.submit {
		padding: 32rpx;

		.btn {
			height: 44px;
			line-height: 44px;
			color: #333333;
			font-size: 16px;
			background: #FFCF0B;
			border-radius: 22px;
			text-align: center;
		}
	}
</style>
